package loader.parser.adapter;

import java.util.Date;
import java.util.HashMap;

public class Adapter4MeiTuan extends SiteAdapter {
	private static HashMap<String, String> maps = new HashMap<String, String>();
	static {
		maps.put("deal_id", "oid");
		maps.put("deal_title", "title");
		maps.put("deal_url", "dealUrl");

		// /*added*/
		// maps.put("deal_rank", "rank");
		maps.put("deal_desc", "dealDesc");
		maps.put("deal_img", "lImageUrl");

		maps.put("city_name", "cityName");

		maps.put("deal_cate", "category");

		maps.put("price", "price");
		maps.put("value", "dealValue");
		maps.put("rebate", "discountPercent");

		maps.put("sales_num", "salesNum");

		maps.put("start_time", "startTime");
		maps.put("end_time", "endTime");
		maps.put("deal_tips", "tips");

		maps.put("shops", "shops");

		maps.put("shop_name", "shopName");
		maps.put("shop_tel", "shopPhone");
		maps.put("shop_addr", "shopAddress");
		maps.put("shop_area", "shopArea");
		maps.put("shop_long", "longtitude");
		maps.put("shop_lat", "latitude");
		/** division **/
		maps.put("did", "pyName");
		maps.put("dname", "name");
		maps.put("dtimezone", "timezone");
		maps.put("dtimezone_offset_gmt", "timezone_offset_gmt");
		maps.put("dlatitude", "latitude");
		maps.put("dlongitude", "longtitude");
	}

	public String getProperName(String oName) {
		return maps.get(oName.trim());
	}

	@Override
	public String getFullUrl(String city) {
		return "http://www.meituan.com/api/v2/" + city + "/deals";
	}

	@Override
	public String getCitiesUrl() {
		return "http://www.meituan.com/api/v1/divisions";
	}

	@Override
	public String getFileDir() {
		Date d = new Date();
		return "C://meituan/" + d.getTime() + ".xml";
	}

	@Override
	public boolean isNewDeal(String nodeName) {
		return nodeName.trim().equals("data");
	}

	@Override
	public boolean isNewCity(String nodeName) {
		return nodeName.trim().equals("division");
	}

	@Override
	public boolean isNewShop(String nodeName) {
		return nodeName.trim().equals("shop");
	}

	@Override
	public String getSiteName() {
		return "meituan";
	}
}
